Fix device mismatch in rotated NMS and visualization on Windows#1099
Open
VISWA00723 wants to merge 1 commit intoopen-mmlab:mainfrom
Open
Fix device mismatch in rotated NMS and visualization on Windows#1099VISWA00723 wants to merge 1 commit intoopen-mmlab:mainfrom
VISWA00723 wants to merge 1 commit intoopen-mmlab:mainfrom
Conversation
|
Viswa V R seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ReDet inference on Windows fails due to device mismatches between tensors used in
rotated NMS and visualization code paths. Specifically, indices produced during
NMS may reside on CPU while the corresponding tensors are on GPU (or vice versa),
leading to runtime errors such as:
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor
Additionally, the visualization pipeline may crash when NumPy indices are passed
to tensor .to() calls.
This PR aims to make ReDet inference stable and usable on Windows without
changing model behavior or training logic.
Modification
This PR introduces defensive device alignment during rotated NMS and
visualization:
Ensures index tensors used for indexing are moved to the same device as the
tensors being indexed.
Adds safe handling for NumPy vs torch.Tensor indices during visualization.
No changes to model architecture, weights, or training behavior.
All modifications are minimal, localized, and inference-only.
BC-breaking
No.
This PR does not change public APIs.
No changes to configuration files or model definitions.
Behavior on Linux remains unchanged.
Downstream projects do not need any code changes.
Use cases
Running ReDet inference on Windows + CUDA
Large-image / patch-based inference using
inference_detector_by_patches
Stable rotated bounding box visualization across platforms
Checklist
Linting
Existing code style is preserved.
Changes follow the current MMRotate code patterns.
Unit tests
No existing unit tests cover Windows-specific CUDA/NMS behavior.
The fix was validated through end-to-end inference on Windows.
Adding automated tests is non-trivial due to platform-specific behavior.
Documentation
No documentation updates are required as behavior and APIs are unchanged.